package cn.edu.pzhu.javaweb.dao.imp;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import cn.edu.pzhu.javaweb.dao.FileMsgDao;
import cn.edu.pzhu.javaweb.pojo.FileMsg;
import cn.edu.pzhu.javaweb.util.DruidUtil;

public class FileMsgDaoImp implements FileMsgDao{

	private JdbcTemplate template = new JdbcTemplate(DruidUtil.getDataSource());
	
	@Override
	public int insert(FileMsg entity) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteById(Integer id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteBatchIds(List<Integer> ids) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateById(FileMsg entity) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public FileMsg selectById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FileMsg> selectBatchIds(List<Integer> ids) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FileMsg> selectAll() {
		String sql="select * from filemsg";
		return template.query(sql, new BeanPropertyRowMapper<>(FileMsg.class));
	}

	@Override
	public List<FileMsg> selectByCondition(FileMsg condition) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long selectCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public long selectCountByCondition(FileMsg condition) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<FileMsg> selectPage(int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FileMsg> selectPageByCondition(FileMsg condition, int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean existsById(Integer id) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int insert(FileMsg entity, Connection con) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<FileMsg> selectByRange(int start, int length) {
	    String sql = "SELECT * FROM filemsg LIMIT ?, ?";
	    try {
	        return template.query(sql, new BeanPropertyRowMapper<>(FileMsg.class), start, length);
	    } catch (Exception e) {
	        e.printStackTrace();
	        return new ArrayList<>();
	    }
	}

	
}
